<?php
class Services_model extends Model {
	function Services_model()
	{
		parent::Model();
		$this->_prefix = $this->config->item('FAL_table_prefix');
        $this->_table = $this->_prefix.'grocery_order';
       
	}
	function getGrocery($id)
	{
		$query = $this->db->query("SELECT id, name, brand, quantity, date_format(date, '%D %b %Y %h:%i %p') as  date, schedule FROM `fa_grocery_order` where userid=".$id);//select name,brand,quantity,date_format('date','%D %M %Y'),schedule from fa_grocery_order where userid=".$id);
//		$this->db->where('userid',$id);
//		$this->db->order_by('id','desc');
//		return $this->db->get($this->_table); // 29th oct 2009 10:34 Am
		return $query; 
	}
    function addGrocery($values)
	{
		$this->db->insert($this->_table,$values);
	}
	function editGrocery($id,$values)
	{
		$this->db->where('id',$id);
		$this->db->update($this->_table,$values);
	} 
	function getEditedRow($id)
	{
		$query = $this->db->query("SELECT id, name, brand, quantity, date_format(date, '%D %b %Y %h:%i %p') as  date, schedule FROM `fa_grocery_order` where id=".$id);
		//$this->db->where('id',$id);
		return $query;
	}
	function deleteGrocery($id)
	{
		$this->db->where('id',$id);
		$this->db->delete($this->_table);
	}
	
}
?>